package com.digitalart.futbol.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.digitalart.futbol.hibernate.ejb.Canton;
import com.digitalart.futbol.hibernate.service.CantonService;

@Controller
@RequestMapping(value="/canton")
public class CantonController {

	@Autowired
	private CantonService cantonServ;
	
	@RequestMapping(value = "/getById/{id}", method = RequestMethod.GET)
	public @ResponseBody Canton getById(@PathVariable("id") int id) {
	
		Canton canton = cantonServ.retriveCanton(id);
		
		return canton;
	}
	
	@RequestMapping(value = "/getAll", method = RequestMethod.GET)
	public @ResponseBody List<Canton> getAll() {
	
		List<Canton> cantones = cantonServ.findAll();
		
		return cantones;
	}
	
	
}
